/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import Server.BUS.StringUlti;
import Server.DTO.InsertQuery;
import org.junit.*;
import static org.junit.Assert.*;

/**
 *
 * @author Trung
 */
public class InsertQueryTest {
    
    public InsertQueryTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

    @Test
    public void testInsertQueryContructor1()
    {
        String queryString = "INSERT INTO tableA VALUES(1, \"abc\")";
        queryString = StringUlti.formatString(queryString);
        //System.out.println(queryString);
        InsertQuery iq = new InsertQuery(queryString);
        assertTrue(iq.keyWord.equalsIgnoreCase("INSERT"));
        assertEquals(0, iq.queryString.compareToIgnoreCase(queryString));
        //System.out.println(iq.getTableName());
        //System.out.println("TableA");
        assertTrue(iq.getTableName().equalsIgnoreCase("tableA"));
        //System.out.println(iq.getValuesString());
        assertTrue(iq.getValuesString().equalsIgnoreCase("(1, \"abc\")"));
    }
    
    @Test
    public void testInsertQueryContructor2()
    {
        String queryString = "  INSERT      INTO        tableA      VALUES(1, \"abc\")       ";
        queryString = StringUlti.formatString(queryString);
        //System.out.println(queryString);
        InsertQuery iq = new InsertQuery(queryString);
        assertTrue(iq.keyWord.equalsIgnoreCase("INSERT"));
        assertEquals(0, iq.queryString.compareToIgnoreCase(queryString));
        //System.out.println(iq.getTableName());
        //System.out.println("TableA");
        assertTrue(iq.getTableName().equalsIgnoreCase("tableA"));
        //System.out.println(iq.getValuesString());
        assertTrue(iq.getValuesString().equalsIgnoreCase("(1, \"abc\")"));
    }
    
    @Test
    public void testInsertQueryContructor3()
    {
        String queryString = "INSERT INTO tableA(id, name) VALUES(1, \"abc\")";
        queryString = StringUlti.formatString(queryString);
        //System.out.println(queryString);
        InsertQuery iq = new InsertQuery(queryString);
        assertTrue(iq.keyWord.equalsIgnoreCase("INSERT"));
        assertEquals(0, iq.queryString.compareToIgnoreCase(queryString));
        //System.out.println(iq.getTableName());
        //System.out.println("TableA");
        assertTrue(iq.getTableName().equalsIgnoreCase("tableA(id, name)"));
        //System.out.println(iq.getValuesString());
        assertTrue(iq.getValuesString().equalsIgnoreCase("(1, \"abc\")"));
    }
    /**
     * Test of getTableName method, of class InsertQuery.
     */
//    @Test
//    public void testGetTableName() {
//        System.out.println("getTableName");
//        InsertQuery instance = new InsertQuery();
//        String expResult = "";
//        String result = instance.getTableName();
//        assertEquals(expResult, result);
//        // TODO review the generated test code and remove the default call to fail.
//        fail("The test case is a prototype.");
//    }

    /**
     * Test of setTableName method, of class InsertQuery.
     */
//    @Test
//    public void testSetTableName() {
//        System.out.println("setTableName");
//        String tableName = "";
//        InsertQuery instance = new InsertQuery();
//        instance.setTableName(tableName);
//        // TODO review the generated test code and remove the default call to fail.
//        fail("The test case is a prototype.");
//    }

    /**
     * Test of getValuesString method, of class InsertQuery.
     */
//    @Test
//    public void testGetValuesString() {
//        System.out.println("getValuesString");
//        InsertQuery instance = new InsertQuery();
//        String expResult = "";
//        String result = instance.getValuesString();
//        assertEquals(expResult, result);
//        // TODO review the generated test code and remove the default call to fail.
//        fail("The test case is a prototype.");
//    }

    /**
     * Test of setValuesString method, of class InsertQuery.
     */
//    @Test
//    public void testSetValuesString() {
//        System.out.println("setValuesString");
//        String valuesString = "";
//        InsertQuery instance = new InsertQuery();
//        instance.setValuesString(valuesString);
//        // TODO review the generated test code and remove the default call to fail.
//        fail("The test case is a prototype.");
//    }
}
